//package com.example.adminframework.config;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.PropertySource;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
//import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//
///**
// * @Date 2020.12.07
// * @Description Web Config
// */
//@Configuration
//@PropertySource(value = "classpath:application.yml", encoding = "utf-8")
//public class WebMvcConfig implements WebMvcConfigurer {
//
//    @Autowired
//    private AuthenticationInterceptor authenticationInterceptor;
//
//    @Value("${server.base.url}")
//    private String serverBaseUrl;
//
////    /**
////     * 重写父类提供的跨域请求处理的接口
////     */
////    @Override
////    public void addCorsMappings(CorsRegistry registry) {
////        // 添加映射路径
////        registry.addMapping("/**")
////                // 放行哪些原始域
////                .allowedOrigins("*")
////                // 是否发送Cookie信息
////                .allowCredentials(true)
////                // 放行哪些原始域(请求方式)
////                .allowedMethods("GET", "POST", "DELETE", "PUT", "OPTIONS", "HEAD")
////                // 放行哪些原始域(头部信息)
////                .allowedHeaders("*")
////                // 暴露哪些头部信息（因为跨域访问默认不能获取全部头部信息）
////                .exposedHeaders("Server","Content-Length", "Authorization", "Access-Token", "Access-Control-Allow-Origin","Access-Control-Allow-Credentials");
////    }
//
//
//    /**
//     * 将所有 RestController 注解作用的类添加/api访问根路径
//     *
//     * @param configurer
//     */
//    @Override
//    public void configurePathMatch(PathMatchConfigurer configurer) {
//        configurer.addPathPrefix(serverBaseUrl, c -> c.isAnnotationPresent(RestController.class));
//    }
//
//    /**
//     * 添加拦截器
//     */
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        //添加权限拦截器
//        registry.addInterceptor(authenticationInterceptor).addPathPatterns("/**").excludePathPatterns("/static/**");
//    }
//
////    /**
////     * 处理请求参数 requestBody 不能复用
////     * @return
////     */
////    @Bean
////    public FilterRegistrationBean getFilterRegistrationBean() {
////        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
////        filterRegistrationBean.setFilter(new CopyRequestBodyFilter());
////        filterRegistrationBean.addUrlPatterns("/*");
////        return filterRegistrationBean;
////    }
//
//}
